/**
 * @Author: 焦质晔
 * @Date: 2019/6/20
 * @Last Modified by: mikey.zhaopeng
 * @Last Modified time: 2019-12-20 17:41:03
 */
import axios from '@/api/fetch';
import * as types from './types';
import SERVER from '@/api/server';

// 登录
export const doLogin = params => axios.post(`${SERVER.DMSCLOUD_BASEDATA}/login`, params, { mark: types.LOGIN });
// GUC登录
export const doGUCLogin = params => axios.post(`${SERVER.DMSCLOUD_BASEDATA}/login/guclogin`, params);
// 发送手机验证码
export const sendPhoneCode = params => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/login/sendSms`, { params });
//点击切换验证码
export const refreshVerification = params => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/login/refreshVerification`, { params });

// 登录初始化
export const initLogin = () => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/login/userDetailData`);

// 获取用户信息
export const getUserInfo = () => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/commonDatas`);
// 获取用户头像
export const getHeadPortrait = () => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/login/getHeadPortrait`);

/*登录接口迁移*/
export const getInfo = token => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/login/getMenus`);

export const getDict = token => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/dicts`);

export const getAuthHandle = token => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/login/handles`);

export const logout = () => axios.get(`/api/logout`);

export const foo = () => axios.get(`/user/success`);

// 收藏
export const favorite = params => axios.post(`${SERVER.DMSCLOUD_BASEDATA}/login/favorite`, params);

// 首页
export const getHomeData = () => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/homePage/queryForSalesHome`);

// 退出jwt接口
export const logoutJwt = params => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/login/logout?jwt=${params}`);


//登陆成功后拦截
export const roleDetail = params => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/login/roleDetail`);

//登陆成功后拦截后保存角色
export const setUserRole = params => axios.post(`${SERVER.DMSCLOUD_BASEDATA}/login/setUserRole`, params);

//查询通知
export const getNoticePanel = params => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/dealer/msgRecord?currentPage=1&pageSize=10&queryCondition=`);

// 通知所有内容
export const noRead = params => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/notification/getNoticeInfo/noRead`);

//通知已读
export const putMsgRecord = params => axios.put(`${SERVER.DMSCLOUD_BASEDATA}/dealer/msgRecord/tz/10651002`,);

//微信登录
export const weChatLogin = params => axios.post(`${SERVER.WXDMSCLOUD_BASEDATA}/wechat/w_login`);
//微信登录
export const weChatCallback = params => axios.post(`${SERVER.WXDMSCLOUD_BASEDATA}/wechat/callback`, params);

// 获取微信验证码
export const sendSms = params => axios.post(`${SERVER.WXDMSCLOUD_BASEDATA}/wechat/sendSms`, params);
//绑定手机号
export const accountBinding = params => axios.post(`${SERVER.WXDMSCLOUD_BASEDATA}/wechat/accountBinding`, params);
//验证码登陆
export const getVerificationCode = (params) => axios.post(`${SERVER.WXDMSCLOUD_BASEDATA}/login/verificationCode?phone=${params.phone}&appId=${params.appId}`);
//正常登录时候绑定手机号/继续绑定手机号
export const postBindingPhone = (params) => axios.post(`${SERVER.WXDMSCLOUD_BASEDATA}/login/bindingPhone`, params);
// 忘记密码
export const getSendSms = (phone, appId) => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/login/sendSms?smsType=3&phone=${phone}&appId=${appId}`);
// 忘记密码重置密码
export const forgetUpdatePassword = (params) => axios.post(`${SERVER.DMSCLOUD_BASEDATA}/login/ignore/forgetUpdatePassword`, params);
//判断售前售后
export const afterSale = phone => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/dealerInfo/afterSale`);
//判断指销售
export const getDealerType = phone => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/dealerInfo/getDealerType`);

//下载APP
export const queryAppVersionByApp = phone => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/version/queryAppVersionByApp`);
//下载appNEW
export const queryDataByAppType = params => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/version/queryDataByAppType`, { params });

// 判断有没有短信微信登陆
export const getSmsWx = (appId) => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/login/getSmsWx?appId=${appId}`);
//90天超期
export const needUpdate = () => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/login/needUpdate`);

